package com.atguigu.hello.auto;

import com.atguigu.hello.bean.HelloProperties;
import com.atguigu.hello.service.HelloService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 杨林
 * @create 2023-09-08 9:48 星期五
 * description:
 */
@Configuration
@ConditionalOnMissingBean(HelloService.class)    //当容器中没有该组件时才将该组件放入到容器中
@EnableConfigurationProperties(HelloProperties.class) //①：加载指定的配置属性类 ②：注册为Spring管理的Bean
public class HelloServiceAutoConfiguration {
    
    @Bean
    public HelloService helloService(){
        HelloService helloService = new HelloService();
        return helloService;
    }
    
}
